package com.mzj.saas.rent;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.ApartmentChargeItemUsage;
import com.haixiaoke.saas.repository.service.IApartmentChargeItemUsageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公寓收费项目用量Controller
 *
 * @author qixi
 * @date 2023-06-16
 */
@RestController
@RequestMapping("/business/usage")
public class ApartmentChargeItemUsageController extends BaseController {
    @Autowired
    private IApartmentChargeItemUsageService apartmentChargeItemUsageService;

    /**
     * 查询公寓收费项目用量列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ApartmentChargeItemUsage apartmentChargeItemUsage) {
        startPage();
        List<ApartmentChargeItemUsage> list = apartmentChargeItemUsageService.selectApartmentChargeItemUsageList(apartmentChargeItemUsage);
        return getDataTable(list);
    }

    /**
     * 获取公寓收费项目用量详细信息
     */
    @GetMapping(value = "/{usageId}")
    public AjaxResult getInfo(@PathVariable("usageId") Long usageId) {
        return success(apartmentChargeItemUsageService.selectApartmentChargeItemUsageByUsageId(usageId));
    }

    /**
     * 新增公寓收费项目用量
     */
    @PostMapping
    public AjaxResult add(@RequestBody ApartmentChargeItemUsage apartmentChargeItemUsage) {
        return toAjax(apartmentChargeItemUsageService.insertApartmentChargeItemUsage(apartmentChargeItemUsage));
    }

    /**
     * 修改公寓收费项目用量
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ApartmentChargeItemUsage apartmentChargeItemUsage) {
        return toAjax(apartmentChargeItemUsageService.updateApartmentChargeItemUsage(apartmentChargeItemUsage));
    }

    /**
     * 删除公寓收费项目用量
     */
    @DeleteMapping("/{usageIds}")
    public AjaxResult remove(@PathVariable Long[] usageIds) {
        return toAjax(apartmentChargeItemUsageService.deleteApartmentChargeItemUsageByUsageIds(usageIds));
    }
}
